<script setup>
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'
import { Timer, HomeFilled, Box, StarFilled, DataAnalysis, Search, Document, Collection, ChatDotRound, Calendar } from '@element-plus/icons-vue'

const route = useRoute()

// 计算当前年份
const currentYear = computed(() => new Date().getFullYear())
const activeIndex = computed(() => route.path)
</script>

<template>
  <el-container class="app-container">
    <el-header class="app-header">
      <div class="header-content responsive-container">
        <div class="logo">
          <el-icon class="logo-icon"><Timer /></el-icon>
          <span>Time Capsule</span>
        </div>
        <el-menu
          :default-active="activeIndex"
          mode="horizontal"
          router
          class="app-menu"
          background-color="transparent"
          text-color="#303133"
          active-text-color="#409eff"
        >
          <el-menu-item index="/">
            <el-icon><HomeFilled /></el-icon>
            <span>首页</span>
          </el-menu-item>
          <el-menu-item index="/container">
            <el-icon><Box /></el-icon>
            <span>时间容器</span>
          </el-menu-item>
          <el-menu-item index="/plan-board">
            <el-icon><Calendar /></el-icon>
            <span>计划看板</span>
          </el-menu-item>
          <el-menu-item index="/evaluation">
            <el-icon><StarFilled /></el-icon>
            <span>经验价值评估</span>
          </el-menu-item>
          <el-menu-item index="/insights">
            <el-icon><DataAnalysis /></el-icon>
            <span>有效性洞察</span>
          </el-menu-item>
          <el-menu-item index="/mind-archive">
            <el-icon><Document /></el-icon>
            <span>思维存档</span>
          </el-menu-item>
          <el-menu-item index="/mind-archive-library">
            <el-icon><Collection /></el-icon>
            <span>存档库</span>
          </el-menu-item>
          <el-menu-item index="/container-search">
            <el-icon><Search /></el-icon>
            <span>容器搜索</span>
          </el-menu-item>
          <el-menu-item index="/campfire">
            <el-icon><ChatDotRound /></el-icon>
            <span>探索营地</span>
          </el-menu-item>
        </el-menu>
      </div>
    </el-header>
    
    <el-main class="app-main">
      <div class="responsive-container">
        <router-view v-slot="{ Component }">
          <transition name="fade" mode="out-in">
            <component :is="Component" />
          </transition>
        </router-view>
      </div>
    </el-main>
    
    <el-footer class="app-footer">
      <div class="responsive-container">
        <div class="footer-content">
          <p>© {{ new Date().getFullYear() }} Time Capsule - 时间胶囊应用</p>
          <div class="footer-links">
            <a href="#">关于我们</a>
            <a href="#">使用帮助</a>
            <a href="#">隐私政策</a>
          </div>
        </div>
      </div>
    </el-footer>
  </el-container>
</template>

<style scoped>
/* 全局样式 */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
}

#app {
  height: 100vh;
}

/* 应用容器 */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 头部样式 */
.app-header {
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  padding: 0;
  height: 64px;
  line-height: 64px;
  position: relative;
  z-index: 10;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  flex-wrap: nowrap; /* 保证横排不换行 */
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color, #409EFF);
  white-space: nowrap; /* 图标与文字保持同一行 */
}

.logo-icon {
  font-size: 24px;
  margin-right: 8px;
}

.app-menu {
  border-bottom: none;
}

.app-menu .el-menu-item {
  font-size: 15px;
  height: 64px;
  line-height: 64px;
}

.app-menu .el-icon {
  margin-right: 4px;
  font-size: 18px;
}

/* 主内容区域 */
.app-main {
  flex: 1;
  padding: 24px 0;
  background-color: var(--background-color, #f5f7fa);
}

.responsive-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

/* 页脚样式 */
.app-footer {
  background-color: #fff;
  color: var(--secondary-text, #909399);
  padding: 20px 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  color: var(--secondary-text, #909399);
  text-decoration: none;
  transition: color 0.3s;
}

.footer-links a:hover {
  color: var(--primary-color, #409EFF);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .app-header {
    height: auto;
    padding: 10px 0;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .app-menu {
    width: 100%;
    margin-top: 10px;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 10px;
  }
}

/* 过渡动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>
